﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Model.Manager;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
namespace Enterprise.Data.Manager
{
    /// <summary>
    /// 经理信箱数据表操作类
    /// </summary>
    public class MsgData
    {

        /// <summary>
        ///  经理信箱数据列表
        /// </summary>
        /// <returns></returns>
        public List<MsgEntity> MsgList()
        {
            List<MsgEntity> list = new List<MsgEntity>();
            string cmd = "Select * from MANAGER_MSG";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                MsgEntity entity = new MsgEntity();
                if (!Convert.IsDBNull(dr["MSGID"])) entity.MsgId = Convert.ToInt32(dr["MSGID"]);
                if (!Convert.IsDBNull(dr["MSGTITLE"])) entity.MsgTitle = Convert.ToString(dr["MSGTITLE"]);
                if (!Convert.IsDBNull(dr["MSGCONTENT"])) entity.MsgContent = Convert.ToString(dr["MSGCONTENT"]);
                if (!Convert.IsDBNull(dr["MSGFUSER"])) entity.MsgFUser = Convert.ToInt32(dr["MSGFUSER"]);
                if (!Convert.IsDBNull(dr["MSGTUSER"])) entity.MsgTUser = Convert.ToInt32(dr["MSGTUSER"]);
                if (!Convert.IsDBNull(dr["MSGISSHOW"])) entity.MsgIsShow = Convert.ToInt32(dr["MSGISSHOW"]);
                if (!Convert.IsDBNull(dr["MSGISANONYMOUS"])) entity.msgIsAnonymous = Convert.ToInt32(dr["MSGISANONYMOUS"]);
                if (!Convert.IsDBNull(dr["MSGFIP"])) entity.MsgFIp = Convert.ToString(dr["MSGFIP"]);
                if (!Convert.IsDBNull(dr["MSGCREATETIME"])) entity.MsgCreateTime = Convert.ToDateTime(dr["MSGCREATETIME"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 经理信箱数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void MsgExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

    }
}
